package com.risems.web.controller;

import com.risems.service.demo.DemoService;
import com.risems.domain.demo.Demo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @Auther: lifeng
 * @Date: 2018/12/15 00:01
 * @Description: 测试类
 */
@RestController
public class DemoController {
    private static final Logger logger = LoggerFactory.getLogger(DemoController.class);
    @Autowired
    private DemoService demoService;

    @RequestMapping("/")
    public String hello(){
        logger.debug("测试类访问成功");
        return "hello:测试类访问成功";
    }

    @RequestMapping("/save")
    public String saveTest(Demo demo){
        logger.debug("保存demo:"+demo);
        demo.setId(UUID.randomUUID().toString());
        demoService.save(demo);
        return "保存成功:"+demo.toString();
    }
}
